<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page"/>

<fmt:setBundle basename="ApplicationMessage"/>
<fmt:setLocale value="zh_CN"/>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp" %>
  <%@ include file="/WEB-INF/include/css.jsp" %>

</head>

<body class="ms-theme-blue">

  <%@ include file="/WEB-INF/include/header.jsp" %>
  <%@ include file="/WEB-INF/include/submenu.jsp" %>
  
  <div class="container-fluid ms-container has-ms-sidemenu">
  
    <ol class="ms-breadcrumb breadcrumb">
      <li class="active">绩效考核管理</li>
    </ol>
  
    <div class="ms-content-layout">
  
      <div class="block-heading">
        <h5>基本信息</h5>
        <c:if test="${not appraisal.finished}">
          <a href="${ctx.host}/appraisals/${appraisal.id}/edit"  class= "pull-right" data-target="#edit" data-toggle="modal">编辑</a>
        </c:if>
      </div>
  
      <div class="form-horizontal ms-form form-personal-info">
  
        <div class="form-group ms-form-group">
          <label class="control-label col-xs-3 ">考核名称：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static">${appraisal.name}</p>
          </div>
          
          <label class="control-label col-xs-2 ">发起人：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static">${persist.user(appraisal.creator).name}</p>
          </div>
        </div>
        
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-3">考核标准：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static">${appraisal.template.name}</p>
          </div>
          
          <label class="control-label col-xs-2">考核类型：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static">${appraisal.target.description}</p>
          </div>
        </div>
        
        <div class="form-group  ms-form-group">
          <label class="control-label col-xs-3">考核时间：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static"><fmt:formatDate value="${appraisal.beginDate}" pattern="yyyy/MM/dd"/>&nbsp;-&nbsp;<fmt:formatDate value="${appraisal.endDate}" pattern="yyyy/MM/dd"/></p>
          </div>
          
          <label class="control-label col-xs-2">是否完成：</label>
          <div class="col-xs-3 pull-left">
            <p class="form-control-static">${appraisal.finished ? '是' : '否'}</p>
          </div>
        </div>
        
      </div>
      
      <div class="block-heading">
        <h5>考核供方信息</h5>
        <c:choose>
          <c:when test="${appraisal.finished}">
            <a href="${ctx.host}/appraisals/${appraisal.id}/export" class="pull-right" data-target="#export" data-toggle="modal">导出</a>
          </c:when>
          <c:otherwise>
            <a href="${ctx.host}/appraisals/${appraisal.id}/results/create" class="pull-right" data-target="#result-create" data-toggle="modal">添加供方</a>
          </c:otherwise>
        </c:choose>
      </div>
      
      <table class="table table-hover ms-table">
        <thead>
          <tr>
            <th>序号</th>
            <th>公司代码</th>
            <th>公司名称</th>
            <th>公司类型</th>
            <th>考核进度</th>
            <th>评价分</th>
            <c:if test="${not appraisal.finished}">
              <th>操作</th>
            </c:if>
          </tr>
        </thead>
  
        <tbody>
          <c:forEach items="${appraisalResults}" var="appraisalResult" varStatus="status">
            <tr>
              <td>${status.count}</td>
              <td>${appraisalResult.code}</td>
              <td>${appraisalResult.name}</td>
              <td>${appraisalResult.appraisal.target.description}</td>
              <td>
                <c:if test="${appraisalResultItemMap.containsKey(appraisalResult.idString)}">
                  <dl style="margin-bottom: 2px;">
                    <c:forEach items="${appraisalResultItemMap[appraisalResult.idString]}" var="appraisalResultItem">
                      <c:choose>
                        <c:when test="${empty appraisalResultItem.realScore}"><dd>${appraisalResultItem.name}：&nbsp;&nbsp;未考核</dd></c:when>
                        <c:otherwise><dd>${appraisalResultItem.name}：&nbsp;&nbsp;<span class="color-red">${appraisalResultItem.realScore}</span>/${appraisalResultItem.score}</dd></c:otherwise>
                      </c:choose>
                    </c:forEach>
                  </dl>
                </c:if>
              </td>
              <td><fmt:formatNumber value="${appraisalResult.scoreTotal}" pattern="0.00" /></td>
              <c:if test="${not appraisal.finished}">
                <td>
                  <a href="${ctx.host}/appraisals/${appraisal.id}/results/${appraisalResult.id}/rate"  data-target="#rate" data-toggle="modal">评分</a>
                  <a href="${ctx.host}/appraisals/${appraisal.id}/results/${appraisalResult.id}/delete"  data-target="#appraisalResultDelete" data-toggle="modal">删除</a>
                </td>
              </c:if>
            </tr>
          </c:forEach>
        </tbody>
      </table>
  
    </div>
  </div>
  
  <%@ include file="/WEB-INF/include/script.jsp" %>
  <d:resource type="script" root="${ctx.resource}/build" src="js/page/supplier/performance/appraisal/appraisal-view.js"/>
  <script type="text/javascript">
    require(['page/supplier/performance/appraisal/appraisal-view'], function (page) {
      page.init()
    })
  </script>

</body>
</html>